package com.woniuxy.util;

import org.springframework.beans.factory.InitializingBean;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;

//从配置文件中读取配置信息
@Component
//InitializingBean:接口为bean提供了属性初始化后的处理方法，它只包括afterPropertiesSet方法，
// 凡是继承该接口的类，在bean的属性初始化后都会执行该方法。
public class ConstantPropertiesUtil implements InitializingBean {

    //地域节点
    @Value("${aliyun.oss.file.endpoint}")
    private String endpoint;
    //accessKeyID
    @Value("${aliyun.oss.file.keyid}")
    private String keyId;
    //密钥
    @Value("${aliyun.oss.file.keysecret}")
    private String keySecret;
    //bucket名称
    @Value("${aliyun.oss.file.bucketname}")
    private String bucketName;

    public static String END_POINT;
    public static String ACCESS_KEY_ID;
    public static String ACCESS_KEY_SECRET;
    public static String BUCKET_NAME;

    @Override
    public void afterPropertiesSet() throws Exception {
        END_POINT = endpoint;
        ACCESS_KEY_ID = keyId;
        ACCESS_KEY_SECRET = keySecret;
        BUCKET_NAME = bucketName;
    }
}
